<template>
    <div>
        <van-button
            v-if="value"
            class="follow-btn"
            type="info"
            color="#3296fa"
            round
            size="small"
            icon="plus"
            :loading="btnloading"
            @click="isfollowfunc"
        >关注</van-button>
        <van-button
            :loading="btnloading"
            @click="isfollowfunc"
            v-else
            class="follow-btn"
            round
            size="small"
        >已关注</van-button>
        =={{aut_id}}
    </div>
</template>
           
<script>
import { followings_api, followingsDel_api } from '@/api/article.js'
import { GET_TOKEN } from '@/utils/storage.js'
export default {
  model: {
    //prop: 'value', //   value
    //event: 'ff' //  触发的是他的input事件
  },
  props: {
    aut_id: {
      type: [String, Number, Object],
      required: true
    },
    value: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      btnloading: false
    }
  },
  methods: {
    async isfollowfunc() {
      //  判断是不是自己
      console.log(this.aut_id, 5555)
      var useId = GET_TOKEN('userInfo').id
      if (useId == this.aut_id) {
        return this.$toast('不能关注自己')
      }

      this.btnloading = true
      // this.isfollow=!this.isfollow

      if (this.value) {
        const { data: res } = await followingsDel_api(this.aut_id)
        console.log(res, 444)
      } else {
        //   发送请求
        const { data: res } = await followings_api({
          target: this.aut_id
        })
        //console.log(res.data.target.toString(), 6666)
      }
      //this.value = !this.value
      //this.$emit('ff', !this.value)
      this.$emit('input', !this.value)
      this.btnloading = false
      //  接口联调
    }
  }
}
</script>
<style scoped>
</style>